package com.itheima.service.impl;


import com.itheima.dao.AccountDao;
import com.itheima.domain.Account;
import com.itheima.service.AccountService;
<<<<<<< Updated upstream
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.DefaultTransactionDefinition;
=======
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.io.IOException;
>>>>>>> Stashed changes

import javax.sql.DataSource;
import java.io.IOException;
import java.util.List;
//对当前类的所有方法添加事务，通常配置在接口上
//@Transactional
public class AccountServiceImpl implements AccountService {

    private AccountDao accountDao;
    public void setAccountDao(AccountDao accountDao) {
        this.accountDao = accountDao;
    }
    //@Transactional 可以配置在类上、接口上、方法上
    //下面的注解配置建议配置在接口方法上或接口上，如果换了实现类还需要重写，比较麻烦。
   /* @Transactional(
            readOnly = false,
            timeout = -1,
            isolation = Isolation.DEFAULT,
            rollbackFor = {java.lang.ArithmeticException.class, IOException.class},
            noRollbackFor = {},
            propagation = Propagation.REQUIRED
    )*/
    public void transfer(String outName, String inName, Double money) {
        accountDao.inMoney(outName,money);
<<<<<<< Updated upstream
        int i = 1/0;
=======
        //int i = 1/0;
>>>>>>> Stashed changes
        accountDao.outMoney(inName,money);
    }

}
